'use strict';

module.exports = (isRender = false) => async (ctx, next) => {
  const bol = ctx.service.user.isManager();
  if (!bol) {
    if (isRender) {
      await ctx.render('error', { msg: '没有权限' });
    } else {
      ctx.status = 403;
      ctx.body = {
        code: 1006,
        msg : '登录信息已过期',
      };
    }
    return;
  }
  await next();
};
